#!/bin/bash

# test for happy path , or the most "standard" way to use higine
# parameters:
# 1:the name of the to-run server-side program
# 2:the process taken to run mpiexec
# (implicit)3:a script called _contains_<program name>_output
# The last param exists because to know a MPI program's exact output is impossible

_prepare_program $1
PROGRAM_ERROR_MESSAGE=$(mpiexec -np $2 $APPSHOME/$1)
_start_server | _contains "$PROGRAM_ERROR_MESSAGE" | _at server &
execute_program $1 $2 | _contains $PROGRAM_ERROR_MESSAGE | _at client 
_prepare_program $3; execute_program $3 $4 | _contains_$3_output $4 | _at state
_kill_server
_collect client server state
